package com.ruoyi.listener;

import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.constant.OperationType;
import com.ruoyi.common.core.domain.entity.socket.bean.PayStatusInfo;
import com.ruoyi.common.core.domain.entity.system.*;
import com.ruoyi.common.core.domain.entity.wsbean.PintuanStatusMsg;
import com.ruoyi.common.core.domain.model.WxRefundReqBody;
import com.ruoyi.common.enums.BoatStatus;
import com.ruoyi.common.enums.OrderStatus;
import com.ruoyi.common.enums.PintuanStatus;
import com.ruoyi.common.enums.Refund_Type;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.handler.websocket.WebSocketMessageHandler;
import com.ruoyi.manager.SocketChannelManager;
import com.ruoyi.manager.WebSocketChannelManager;
import com.ruoyi.pay.service.IWxPayV3Service;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.IScenicOperationDynamicInfoService;
import com.ruoyi.system.service.ISysBoatService;
import com.ruoyi.system.service.ISysOrderService;
import com.ruoyi.system.service.IUserBoatOrderInfoService;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * Redis键过期事件监听器。
 */
@Slf4j
@Component
public class RedisKeyExpiredListener extends KeyExpirationEventMessageListener {

    @Resource
    private SysPintuanTypeMapper sysPintuanTypeMapper;

    @Resource
    private SysBoatMapper sysBoatMapper;

    @Autowired
    private ISysBoatService sysBoatService;

    @Resource
    private SysOrderMapper sysOrderMapper;

    @Autowired
    private IWxPayV3Service wxPayV3Service;

    @Resource
    private SysJishiOrderMapper sysJishiOrderMapper;

    @Resource
    private SysTaocanOrderMapper sysTaocanOrderMapper;

    @Autowired
    private IUserBoatOrderInfoService userBoatOrderInfoService;

    @Resource
    private SysPintuanChildrenOrderMapper sysPintuanChildrenOrderMapper;

    @Resource
    private SysPintuanParentOrderMapper sysPintuanParentOrderMapper;

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");

    /**
     * Creates new {@link MessageListener} for {@code __keyevent@*__:expired} messages.
     *
     * @param listenerContainer must not be {@literal null}.
     */
    public RedisKeyExpiredListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    @Override
    public void onMessage(Message message, byte[] pattern) {
        // 过期的Key
        String expiredKey = message.toString();
        log.info("expiredKey: {}", expiredKey);

        if (expiredKey.startsWith(CacheConstants.Pintuan_Order_Redis_Key)) { //当前过期的是拼团订单拼团倒计时redis key
            String[] keyStrs = expiredKey.split(":");
            String boatIdStr = keyStrs[1];
            //当前redis key过期，说明拼团失败
            if (StringUtils.isNotEmpty(boatIdStr)) {
                Long boatId = Long.parseLong(boatIdStr);
                UserBoatOrderInfo userBoatOrderInfo = userBoatOrderInfoService.selectBoatOrderInfoByBoatId(boatId);
                if (Objects.isNull(userBoatOrderInfo)) return;

                SysPintuanParentOrder sysPintuanParentOrder = sysPintuanParentOrderMapper.selectSysPintuanParentOrderByOrderId(userBoatOrderInfo.getOrderId());
                if (Objects.isNull(sysPintuanParentOrder)) return;

                log.info("拼团失败！拼团父订单id：{}", sysPintuanParentOrder.getOrderId());

                PintuanStatusMsg pintuanStatusMsg = new PintuanStatusMsg();
                pintuanStatusMsg.setBoatId(sysPintuanParentOrder.getBoatId());
                //设置拼团状态为：拼团失败
                pintuanStatusMsg.setStatus(1);

                Date closedTime = new Date();

                //处理各拼团子订单
                List<SysPintuanChildrenOrder> pintuanChildrenOrderList = sysPintuanParentOrder.getPintuanChildrenOrderList();
                pintuanChildrenOrderList.forEach(childrenOrder -> {
                    //通知各拼团用户拼团失败
                    Channel miniProgramChannel = WebSocketChannelManager.getMiniprogramWebsocketChannelByUserId(childrenOrder.getUserId());
                    if (Objects.nonNull(miniProgramChannel)) {
                        WebSocketMessageHandler.notifyClientSidePintuanStatusModified(miniProgramChannel, pintuanStatusMsg);
                    }

                    //将各子订单的状态更新为已关闭
                    childrenOrder.setOrderStatus(OrderStatus.Closed.getCode());
                    childrenOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                    childrenOrder.setClosedTime(closedTime);

                    //更新子订单的拼团状态为“拼团失败”
                    childrenOrder.setPintuanStatus(PintuanStatus.GroupBookingFailed.getCode());
                    childrenOrder.setPintuanStatusDesc(PintuanStatus.GroupBookingFailed.getInfo());

                    childrenOrder.setRemark("拼团失败，订单已被关闭");
                    sysPintuanChildrenOrderMapper.updateSysPintuanChildrenOrder(childrenOrder);

                    //主动给用户退款(退还用户当前订单已支付的押金及费用)
                    WxRefundReqBody refundRequestBody = new WxRefundReqBody();
                    refundRequestBody.setOrderId(childrenOrder.getOrderId());
                    refundRequestBody.setOrderType(2);
                    refundRequestBody.setRefundType(Refund_Type.Refund_All.ordinal());
                    refundRequestBody.setReason("拼团失败，订单被关闭，已支付的款项原路退回.");
                    wxPayV3Service.refund(refundRequestBody);
                });

                //更新父订单的状态
                sysPintuanParentOrder.setOrderStatus(OrderStatus.Closed.getCode());
                sysPintuanParentOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                sysPintuanParentOrder.setClosedTime(closedTime);
                sysPintuanParentOrder.setRemark("拼团失败，订单已被关闭");

                //更新父订单的拼团状态为“拼团失败”
                sysPintuanParentOrder.setPintuanStatus(PintuanStatus.GroupBookingFailed.getCode());
                sysPintuanParentOrder.setPintuanStatusDesc(PintuanStatus.GroupBookingFailed.getInfo());
                //更新数据库中父订单
                sysPintuanParentOrderMapper.updateSysPintuanParentOrder(sysPintuanParentOrder);

                //删除船只订单关联对象
                userBoatOrderInfoService.deleteUserBoatOrderInfoByUserId(sysPintuanParentOrder.getUserId());

                //将船只状态从"拼团中"更新为“空闲”
                SysBoat sysBoat = new SysBoat();
                sysBoat.setBoatId(sysPintuanParentOrder.getBoatId());
                sysBoat.setStatus(BoatStatus.Idle.getCode());
                sysBoat.setStatusDesc(BoatStatus.Idle.getInfo());
                sysBoatMapper.updateSysBoat(sysBoat);
            }
        } else if (expiredKey.startsWith(CacheConstants.Order_Pay_Status_Redis_Key)) { //当前过期的是订单支付状态redis key
            String[] keyStrs = expiredKey.split(":");
            String orderId = keyStrs[1];
            String orderTypeStr = keyStrs[2];
            if (StringUtils.isNotEmpty(orderId) && StringUtils.isNotEmpty(orderTypeStr)) {
                int orderType = Integer.valueOf(orderTypeStr);
                if (orderType == 0) { //计时计费订单
                    SysJishiOrder sysJishiOrder = sysJishiOrderMapper.selectSysJishiOrderByOrderId(orderId);
                    if (Objects.isNull(sysJishiOrder)) return;
//                    log.info("sysJishiOrder: {}", sysJishiOrder);

                    String depositOutOrderNo = sysJishiOrder.getDepositOutOrderNo();
                    //不管哪种类型的订单，订单支付状态redis key过期说明该订单在key的有效期内一直未支付(因为如果有效期内支付了会主动删除该key，不会触发过期回调事件)，
                    // 所以在此过期回调方法中直接关闭订单即可。
                    log.info("计时计费订单[orderId:{}]支付超时，现将其关闭！", orderId);
                    sysJishiOrder.setOrderStatus(OrderStatus.Closed.getCode()); //订单状态。0：待付款，1：待使用，2：使用中，3: 已关闭，4：已完成
                    sysJishiOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                    sysJishiOrder.setClosedTime(new Date());
                    sysJishiOrder.setRemark("用户支付超时，订单被关闭");
                    sysJishiOrderMapper.updateSysJishiOrder(sysJishiOrder);

                    //删除船只订单关联对象
                    userBoatOrderInfoService.deleteUserBoatOrderInfoByUserId(sysJishiOrder.getUserId());

                    //更新船只状态为“空闲”
                    Long boatId = sysJishiOrder.getBoatId();
                    sysBoatService.updateBoatStatusByBoadId(boatId, BoatStatus.Idle);

                    //调用微信支付接口关闭当前订单
                    wxPayV3Service.closeOrder(depositOutOrderNo);

                    //取消该订单id对应的支付状态查询定时器。
                    wxPayV3Service.cancelPayStatusQueryTimer(depositOutOrderNo);

                    //创建运营动态信息
                    ScenicOperationDynamicInfo scenicOperationDynamicInfo = new ScenicOperationDynamicInfo();
                    scenicOperationDynamicInfo.setOperationType(OperationType.Order_Closed);
                    scenicOperationDynamicInfo.setScenicId(sysJishiOrder.getScenicId());
                    scenicOperationDynamicInfo.setBoatId(sysJishiOrder.getBoatId());
                    scenicOperationDynamicInfo.setBoatCode(sysJishiOrder.getBoatCode());
//                    scenicOperationDynamicInfo.setBoatIdentityId(boatOrderInfo.getBoatIdentityId());
                    scenicOperationDynamicInfo.setOrderId(orderId);
                    scenicOperationDynamicInfo.setOrderType(orderType);
                    scenicOperationDynamicInfo.setUserId(sysJishiOrder.getUserId());
                    Date createTime = new Date();
                    scenicOperationDynamicInfo.setCreateTime(createTime);
                    IScenicOperationDynamicInfoService operationInfoService = SpringUtils.getBean(IScenicOperationDynamicInfoService.class);
                    scenicOperationDynamicInfo.setContent(String.format("%s, %s船用户支付超时，订单被关闭!", sdf.format(createTime), sysJishiOrder.getBoatCode()));
                    operationInfoService.insertOperationInfo(scenicOperationDynamicInfo);

                    //向景区监控中心发送运营动态信息
                    WebSocketMessageHandler.sendMsgToScenicAdmin(sysJishiOrder.getScenicId(), scenicOperationDynamicInfo);
                } else if (orderType == 1) { //套餐计费订单
                    SysTaocanOrder sysTaocanOrder = sysTaocanOrderMapper.selectSysTaocanOrderByOrderId(orderId);
                    if (Objects.isNull(sysTaocanOrder)) return;

                    String depositAndFeeOutOrderNo = sysTaocanOrder.getDepositAndFeeOutOrderNo();
                    log.info("套餐计费订单[orderId:{}]支付超时，现将其关闭！", orderId);
                    sysTaocanOrder.setOrderStatus(OrderStatus.Closed.getCode()); //订单状态。0：待付款，1：待使用，2：使用中，3: 已关闭，4：已完成
                    sysTaocanOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                    sysTaocanOrder.setClosedTime(new Date());
                    sysTaocanOrder.setRemark("用户支付超时，订单被关闭");
                    sysTaocanOrderMapper.updateSysTaocanOrder(sysTaocanOrder);

                    //删除船只订单关联对象
                    userBoatOrderInfoService.deleteUserBoatOrderInfoByUserId(sysTaocanOrder.getUserId());

                    //更新船只状态为“空闲”
                    Long boatId = sysTaocanOrder.getBoatId();
                    sysBoatService.updateBoatStatusByBoadId(boatId, BoatStatus.Idle);

                    //调用微信支付接口关闭当前订单
                    wxPayV3Service.closeOrder(depositAndFeeOutOrderNo);

                    //取消该订单id对应的支付状态查询定时器。
                    wxPayV3Service.cancelPayStatusQueryTimer(depositAndFeeOutOrderNo);

                    //创建运营动态信息
                    ScenicOperationDynamicInfo scenicOperationDynamicInfo = new ScenicOperationDynamicInfo();
                    scenicOperationDynamicInfo.setOperationType(OperationType.Order_Closed);
                    scenicOperationDynamicInfo.setScenicId(sysTaocanOrder.getScenicId());
                    scenicOperationDynamicInfo.setBoatId(sysTaocanOrder.getBoatId());
                    scenicOperationDynamicInfo.setBoatCode(sysTaocanOrder.getBoatCode());
//                    scenicOperationDynamicInfo.setBoatIdentityId(boatOrderInfo.getBoatIdentityId());
                    scenicOperationDynamicInfo.setOrderId(orderId);
                    scenicOperationDynamicInfo.setOrderType(orderType);
                    scenicOperationDynamicInfo.setUserId(sysTaocanOrder.getUserId());
                    Date createTime = new Date();
                    scenicOperationDynamicInfo.setCreateTime(createTime);
                    IScenicOperationDynamicInfoService operationInfoService = SpringUtils.getBean(IScenicOperationDynamicInfoService.class);
                    scenicOperationDynamicInfo.setContent(String.format("%s, %s船用户支付超时，订单被关闭!", sdf.format(createTime), sysTaocanOrder.getBoatCode()));
                    operationInfoService.insertOperationInfo(scenicOperationDynamicInfo);

                    //向景区监控中心发送运营动态信息
                    WebSocketMessageHandler.sendMsgToScenicAdmin(sysTaocanOrder.getScenicId(), scenicOperationDynamicInfo);
                } else if (orderType == 2) { //拼团订单
                    SysPintuanChildrenOrder sysPintuanChildrenOrder = sysPintuanChildrenOrderMapper.selectSysPintuanChildrenOrderByOrderId(orderId);
                    if (Objects.isNull(sysPintuanChildrenOrder)) return;

                    String depositAndFeeOutOrderNo = sysPintuanChildrenOrder.getDepositAndFeeOutOrderNo();
                    log.info("拼团订单[orderId:{}]支付超时，现将其关闭！", orderId);
                    sysPintuanChildrenOrder.setOrderStatus(OrderStatus.Closed.getCode()); //订单状态。0：待付款，1：待使用，2：使用中，3: 已关闭，4：已完成
                    sysPintuanChildrenOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                    sysPintuanChildrenOrder.setClosedTime(new Date());
                    sysPintuanChildrenOrder.setRemark("用户支付超时，订单被关闭");
                    sysPintuanChildrenOrderMapper.updateSysPintuanChildrenOrder(sysPintuanChildrenOrder);

                    //调用微信支付接口关闭当前订单
                    wxPayV3Service.closeOrder(depositAndFeeOutOrderNo);
                }
                //停止定期查询该订单的支付状态的定时器
                wxPayV3Service.stopCheckPayStatusTimer(orderId);
            }
        } else if (expiredKey.startsWith(CacheConstants.Order_Confirm_On_Boat_Status_Redis_Key)) { //当前过期的是扫码确认上船状态redis key
            //此时说明持有当前订单的用户扫码确认上船超时了
            String[] keyStrs = expiredKey.split(":");
            String orderId = keyStrs[1];
            String orderTypeStr = keyStrs[2];
            if (StringUtils.isNotEmpty(orderId) && StringUtils.isNotEmpty(orderTypeStr)) {
                int orderType = Integer.valueOf(orderTypeStr);
                //退款类型
                int refundType = 0;
                //退款原因
                String refundReason = "用户扫码确认上船超时,订单被关闭,商家主动退款";
                if (orderType == 0) { //计时计费订单
                    SysJishiOrder sysJishiOrder = sysJishiOrderMapper.selectSysJishiOrderByOrderId(orderId);
                    if (Objects.isNull(sysJishiOrder)) return;
//                    log.info("sysJishiOrder: {}", sysJishiOrder);

                    //由于用户在指定的时间内未完成扫码确认上船，因此需关闭该订单，并给用户主动退款
                    sysJishiOrder.setOrderStatus(OrderStatus.Closed.getCode());
                    sysJishiOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                    sysJishiOrder.setClosedTime(new Date());
                    sysJishiOrder.setRemark("用户扫码确认上船超时，订单被关闭，已支付的款项将原路退回.");
                    sysJishiOrderMapper.updateSysJishiOrder(sysJishiOrder);

                    //计时计费此时只退押金
                    refundType = Refund_Type.Refund_Deposit.ordinal();

                    //删除船只订单关联对象
                    userBoatOrderInfoService.deleteUserBoatOrderInfoByUserId(sysJishiOrder.getUserId());

                    //更新船只状态为“空闲”
                    Long boatId = sysJishiOrder.getBoatId();
                    sysBoatService.updateBoatStatusByBoadId(boatId, BoatStatus.Idle);

                    //主动给用户退款(退还用户当前订单已支付的费用)
                    WxRefundReqBody refundRequestBody = new WxRefundReqBody();
                    refundRequestBody.setOrderId(orderId);
                    refundRequestBody.setOrderType(orderType);
                    refundRequestBody.setRefundType(refundType);
                    refundRequestBody.setReason(refundReason);
                    wxPayV3Service.refund(refundRequestBody);

                    //创建运营动态信息
                    ScenicOperationDynamicInfo scenicOperationDynamicInfo = new ScenicOperationDynamicInfo();
                    scenicOperationDynamicInfo.setOperationType(OperationType.Order_Closed);
                    scenicOperationDynamicInfo.setBoatId(sysJishiOrder.getBoatId());
                    scenicOperationDynamicInfo.setBoatCode(sysJishiOrder.getBoatCode());
                    scenicOperationDynamicInfo.setScenicId(sysJishiOrder.getScenicId());
                    scenicOperationDynamicInfo.setOrderId(orderId);
                    scenicOperationDynamicInfo.setOrderType(orderType);
                    scenicOperationDynamicInfo.setUserId(sysJishiOrder.getUserId());
                    Date createTime = new Date();
                    scenicOperationDynamicInfo.setCreateTime(createTime);
                    IScenicOperationDynamicInfoService operationInfoService = SpringUtils.getBean(IScenicOperationDynamicInfoService.class);
                    scenicOperationDynamicInfo.setContent(String.format("%s, %s船用户上船扫码超时，订单被关闭!", sdf.format(createTime), sysJishiOrder.getBoatCode()));
                    operationInfoService.insertOperationInfo(scenicOperationDynamicInfo);

                    //向景区监控中心发送运营动态信息
                    WebSocketMessageHandler.sendMsgToScenicAdmin(sysJishiOrder.getScenicId(), scenicOperationDynamicInfo);
                } else if (orderType == 1) { //套餐计费订单
                    SysTaocanOrder sysTaocanOrder = sysTaocanOrderMapper.selectSysTaocanOrderByOrderId(orderId);
                    if (Objects.isNull(sysTaocanOrder)) return;

                    //由于用户在指定的时间内未完成扫码确认上船，因此需关闭该订单，并给用户主动退款
                    sysTaocanOrder.setOrderStatus(OrderStatus.Closed.getCode());
                    sysTaocanOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                    sysTaocanOrder.setClosedTime(new Date());
                    sysTaocanOrder.setRemark("用户扫码确认上船超时，订单被关闭，已支付的款项将原路退回.");
                    sysTaocanOrderMapper.updateSysTaocanOrder(sysTaocanOrder);

                    //套餐计费订单此时需退用户已支付的押金和套餐费用
                    refundType = Refund_Type.Refund_All.ordinal();

                    //删除船只订单关联对象
                    userBoatOrderInfoService.deleteUserBoatOrderInfoByUserId(sysTaocanOrder.getUserId());

                    //更新船只状态为“空闲”
                    Long boatId = sysTaocanOrder.getBoatId();
                    sysBoatService.updateBoatStatusByBoadId(boatId, BoatStatus.Idle);

                    //主动给用户退款(退还用户当前订单已支付的费用)
                    WxRefundReqBody refundRequestBody = new WxRefundReqBody();
                    refundRequestBody.setOrderId(orderId);
                    refundRequestBody.setOrderType(orderType);
                    refundRequestBody.setRefundType(refundType);
                    refundRequestBody.setReason(refundReason);
                    wxPayV3Service.refund(refundRequestBody);

                    //创建运营动态信息
                    ScenicOperationDynamicInfo scenicOperationDynamicInfo = new ScenicOperationDynamicInfo();
                    scenicOperationDynamicInfo.setOperationType(OperationType.Order_Closed);
                    scenicOperationDynamicInfo.setBoatId(sysTaocanOrder.getBoatId());
                    scenicOperationDynamicInfo.setBoatCode(sysTaocanOrder.getBoatCode());
                    scenicOperationDynamicInfo.setScenicId(sysTaocanOrder.getScenicId());
                    scenicOperationDynamicInfo.setOrderId(orderId);
                    scenicOperationDynamicInfo.setOrderType(orderType);
                    scenicOperationDynamicInfo.setUserId(sysTaocanOrder.getUserId());
                    Date createTime = new Date();
                    scenicOperationDynamicInfo.setCreateTime(createTime);
                    IScenicOperationDynamicInfoService operationInfoService = SpringUtils.getBean(IScenicOperationDynamicInfoService.class);
                    scenicOperationDynamicInfo.setContent(String.format("%s, %s船用户上船扫码超时，订单被关闭!", sdf.format(createTime), sysTaocanOrder.getBoatCode()));
                    operationInfoService.insertOperationInfo(scenicOperationDynamicInfo);

                    //向景区监控中心发送运营动态信息
                    WebSocketMessageHandler.sendMsgToScenicAdmin(sysTaocanOrder.getScenicId(), scenicOperationDynamicInfo);
                } else if (orderType == 2) { //拼团订单
                    //代码走到此处说明当前的拼团订单中存在有用户未完成扫码确认上船，因为如果所有的人都完成了扫码上船则会取消上船倒计时，代码就不会走到此处。

                    //拼团订单上船超时后的处理方式：
                    //1，已扫码上船的用户的订单开始计费；
                    //2，未扫码上船的用户的订单直接关闭，且不退款。
                    SysPintuanParentOrder sysPintuanParentOrder = sysPintuanParentOrderMapper.selectSysPintuanParentOrderByOrderId(orderId);
                    if (Objects.isNull(sysPintuanParentOrder)) return;

                    List<SysPintuanChildrenOrder> pintuanChildrenOrderList = sysPintuanParentOrder.getPintuanChildrenOrderList();
                    if (Objects.nonNull(pintuanChildrenOrderList) && pintuanChildrenOrderList.size() > 0) {
                        pintuanChildrenOrderList.forEach(childrenOrder -> {
                            if (childrenOrder.getOnBoatStatus() != 1) { //未完成扫码上船，直接关闭订单，且不退款。
                                childrenOrder.setOrderStatus(OrderStatus.Closed.getCode());
                                childrenOrder.setOrderStatusDesc(OrderStatus.Closed.getInfo());
                                childrenOrder.setClosedTime(new Date());
                                childrenOrder.setRemark("当前拼团订单未在指定时限内完成扫码上船，订单被关闭，已支付的款项不予退还.");
                            }

                            sysPintuanChildrenOrderMapper.updateSysPintuanChildrenOrder(childrenOrder);
                        });
                    }

                    //发送消息给当前订单对应的船端软件，告知当前拼团订单中的所有用户均已支付成功，且均已扫码确认上船成功，船锁可以开启了。
                    Long boatId = sysPintuanParentOrder.getBoatId();
                    Channel socketChannel = SocketChannelManager.getSocketChannelByBoatId(boatId);
                    if (Objects.nonNull(socketChannel)) {
                        SocketChannelManager.sendPayStatusInfoMessage(socketChannel, new PayStatusInfo((byte) 1));
                    }

                    //模拟开锁及行驶
                    ISysOrderService sysOrderService = SpringUtils.getBean(ISysOrderService.class);
                    sysOrderService.mockUnlockAndUsingForPintuanOrder(sysPintuanParentOrder, 10000L, 20000L);
                }


            }
        }
    }
}
